import React from "react"

class Fah extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      fahrenheit: 0
    }
  }

  fahChange = (e) => {
    // this.setState({fahrenheit: e.target.value})
    this
      .props
      .onFahChange(e.target.value)
  }

  toFah = () => {
    return (this.props.celsius * 9 / 5) + 32
  }

  render() {
    return (
      <div>
        <h3>华氏度：{this.props.fahrenheit
            ? this.props.fahrenheit
            : ''}</h3>
        <input
          type='text'
          value={this.props.fahrenheit
          ? this.props.fahrenheit
          : ''}
          onChange={this.fahChange}/>
      </div>
    )
  }
}

export default Fah